import axios from '@/libs/api.request'
import { getToken } from '@/libs/util'

export const requestData = (url, method, opt) => {
  for(let i in opt){
    if(opt[i]===''){
      delete opt[i];
    }
  }
  if (method == 'get') {
    return axios.request({
      url: url + `?token=${getToken()}`,
      params: {
        ...opt
      },
      method,
    })
  } else if (method == 'post') {
    return axios.request({
      url: url + `?token=${getToken()}`,
      data: {
        ...opt
      },
      method: 'post'
    })
  }
}
export const getData = (url, opt) => {
  return axios.request({
    url: '/supers' + url + `?token=${getToken()}`,
    data: {
      ...opt
    },
    method: 'post'
  })
}
export const uploadImg = formData => {
  return axios.request({
    url: 'image/upload',
    data: formData
  })
}
